﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TypeMock.ArrangeActAssert;
using WorkItemAnalyser.Core.Parsers;

namespace WorkItemAnalyser.Test.ParserTests
{
    [TestClass]
    public class TextRuleParserTests
    {
        [Isolated]
        [TestMethod]
        public void TextRuleParser_GetRules_ShouldReturnEmptyForEmptyString()
        {
           //Arrange
            var fakeIAssertionParser = Isolate.Fake.Instance<IAssertionParser>();
            var textRuleParser = new TextRuleParser(new IAssertionParser[]{fakeIAssertionParser});
            
            //Act
            var rules = textRuleParser.RetrieveRules("");

            //Assert
            Assert.IsTrue(rules.Count() == 0);
        } 

        [Isolated]
        [TestMethod]
        public void TextRuleParser_GetRules_ShouldReturnEmptyForNonConformingString()
        {
            //Arrange
            var fakeIAssertionParser = Isolate.Fake.Instance<IAssertionParser>();
            var textRuleParser = new TextRuleParser(new IAssertionParser[] {fakeIAssertionParser});

            var rules = textRuleParser.RetrieveRules("a non conforming string");

            Assert.IsTrue(rules.Count() == 0);
        }
    }
}
